<?php
class root{
	var $errorhl = '';
	var $R = array(
			'global' => true,
			'page1' => false,
			'page2' => false,
			'page3' => false,
			'page4' => false,
			'page5' => false,
			'page6' => false,
			'page7' => false,
			'npfe' => false
		 );
	function InitGlobalRoot($now_user = ""){
		global $db;
		$m_root = "";
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			//开始定义各个权限
			$this->R['page1'] = $db->Get("page1")=="T" ? true:false;
			$this->R['page2'] = $db->Get("page2")=="T" ? true:false;
			$this->R['page3'] = $db->Get("page3")=="T" ? true:false;
			$this->R['page4'] = $db->Get("page4")=="T" ? true:false;
			$this->R['page5'] = $db->Get("page5")=="T" ? true:false;
			$this->R['npfe'] = $db->Get("npfe")=="T" ? true:false;
		}
	}
	function getpageroot($now_user = "",$page = "") {
		global $db;
		$m_root = "";
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			$m_root = $db->Get("page".$page);
			if ($m_root == 'T') {
				$m_root = true;
			}else {
				$m_root = false;
			}
		}
		return $m_root;
	}
	function cicwo($now_user = ""){
		global $db;
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			$m_root = $db->Get("chekwaitorder");
			if ($m_root == 'T') {
				$m_root = true;
			}else {
				$m_root = false;
			}
		}
		return $m_root;
	}
	function cicngo($now_user = ""){
		global $db;
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			$m_root = $db->Get("chekngorder");
			if ($m_root == 'T') {
				$m_root = true;
			}else {
				$m_root = false;
			}
		}
		return $m_root;
	}
	function cigdcl($now_user = ""){
		global $db;
		$m_root = false;
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			$m_root = $db->Get("gdcl");
			if ($m_root == 'T') {
				$m_root = true;
			}else {
				$m_root = false;
			}
		}
		return $m_root;
	}
	function cigdsc($now_user = ""){
		global $db;
		$gid = $this->chekgroupid($now_user);
		$db->ExeQuerySql("SELECT * FROM `cu_usergroup` WHERE number='$gid'");
		if($db->FetchRow()){
			$m_root = $db->Get("gdsc");
			if ($m_root == 'T') {
				$m_root = true;
			}else {
				$m_root = false;
			}
		}
		return $m_root;
	}
	function chekgroupid($now_user = ""){
		global $db;
		$m_root = "";
		$groupid = 0;
		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
		if($db->FetchRow()){
			$groupid = $db->Get("root");/* 获取用户组序号 */
		}
		return $groupid;
	}
	function stoproot(){
		$this->errorhl = '<div id="stoproot"><img src="./image/style/t2.png" /><br>对不起！你目前无权操作这个功能！<br><br>可能您未达到可以操作该功能的能力，本系统的所有重要功能皆由管理员提供权限，如有任何问题请与管理员联系！</div>';
	}
	function rooterrorhtml(){
		return $this->errorhl;
	}
}